package com.google.code.timeeditapplication.view.implementation;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.widget.Button;

/**
 * @author Sam Odeh
 * @version 0.1
 * @since 2011-10-11
 */
public class CustomScheduleObject extends Button {

	/**
	 * class constructor
	 * 
	 * @param context
	 */
	public CustomScheduleObject(final Context context) {
		super(context);
	}

	private int width;
	private int height;
	private String name;
	private String location;
	private String time;
	private int textSize = 16;

	/**
	 * Creates a schedule item (lesson)
	 * 
	 * Creates a Schedule item(Button) and sets the height and width. It also
	 * adds name, location and time as text to the item.
	 * 
	 * @param w
	 *            The buttons width
	 * @param h
	 *            The buttons height
	 * @param n
	 *            The class name
	 * @param l
	 *            The location
	 * @param t
	 *            The Time, e.g. 10.00-11.45
	 * @param s
	 *            Text size on the button
	 * 
	 * @return The created Schedule Item(Button)
	 */
	public CustomScheduleObject createScheduleObject(final int w, final int h,
			final String n, final String l, final String t, final int s) {
		this.width = w;
		this.height = h;
		this.name = n;
		this.location = l;
		this.time = t;
		this.textSize = s;

		setLayout();
		setWillNotDraw(false);

		return this;

	}

	// Sets the layout with the given parameters
	private void setLayout() {
		setHeight(this.height);
		setWidth(this.width);
		this.setText("Time: " + this.time + "\n" + this.name + "\n"
				+ this.location);
		this.setTextColor(Color.BLUE);
		this.setTextSize(this.textSize);
	}

	/**
	 * @inheritDoc
	 */
	@Override
	public void onDraw(final Canvas canvas) {
		super.onDraw(canvas);
	}
}
